/*
*	create by  jack ,20211108
*	
*	描述  
*		  该文件提供了一套线程调用的接口，屏蔽具体实现细节,以达到应用程序可以在不同的平台上联合调试。
*   修改记录：[内容][作者][时间]
*	
*/
#ifndef _SANJI_GUI_OBJECT_H_
#define _SANJI_GUI_OBJECT_H_

#include <stdio.h>
#include "define_comm.h"
#include "list.h"

#ifdef __cplusplus
extern "C"{
#endif

#define DISPLAY_MAX_OBJ 4

enum gui_object_type
{
	GUI_OBJECT_TYPE_FILE=1,
    GUI_OBJECT_TYPE_DIR=2,
};

struct desktop_signal_value
{
    sj_int8 gps;
    sj_int8 value_4g;
    sj_int8 signal;
    sj_int8 camera;
    sj_int8 hard_disk;
    sj_int8 sd_card;
};


typedef void (*display_pic_callback)(sj_int8 x,sj_int8 y,struct desktop_signal_value *val);
typedef void (*display_callback)(sj_int8 x,sj_int8 y,sj_char *content,sj_int8 mode);

struct lcd_display_tools
{
    display_callback display;
    display_pic_callback display_pic;
};


typedef int (*gui_object_content)(struct lcd_display_tools *tools);

struct gui_object{
	struct gui_object *parent;
	struct gui_object *children;
    struct gui_object *display_sub_first;// the first display of sub object;
    struct list peer;
    struct list_iter child_iter; 
    gui_object_content content;
	const char *name;
    sj_int8 object_type;
    sj_int8 child_num;
    sj_int8 self_index_in_parent;
    sj_int8 into_flag; //slj add, judge object_type is FILE or DIR
};

struct gui_console
{
	struct gui_object *current;   
    int current_input_type;//menu up down ok none
    int current_object_duration; //no action timeout
};

enum SYSTEM_BUTTON_TYPE  //slj add
{
  BUTTON_NONE=0,
  BUTTON_MENU=1,
  BUTTON_UP=2,
  BUTTON_DOWN=3,
  BUTTON_OK=4,
  BUTTON_PRINT=5,
};

#define GUI_OBJECT(name) struct gui_object name

#define GUI_OBJECT_INIT(name,str) struct gui_object name;gui_object_init(&(name),str)

#define GUI_CONSOLE_INIT(name) struct gui_console name={NULL,0}

#define to_gui_object(obj) container_of(obj, struct gui_object,peer)

#define is_entry_object(obj) (obj->parent==NULL?1:0)

#define init_sub_first_display_obj(obj,obj_child) (obj = obj_child)

int lcd_show_content(struct gui_console *gs_console,struct lcd_display_tools *tools);//slj add for test

void gui_object_add_child(struct gui_object *obj,struct gui_object *sub);

int gui_object_get_child_num(struct gui_object *obj);

void gui_object_add_peer(struct gui_object *obj,struct gui_object *peer);//slj add

struct list *list_next(struct list *l);

struct list *list_prev(struct list *l);

void gui_object_init(struct gui_object *obj,const char *name);

void gui_object_add_content(struct gui_object *obj,gui_object_content *content);

struct gui_object *gui_object_get_priv(struct gui_object *obj);

struct gui_object *gui_object_get_next(struct gui_object *obj);

struct gui_object *gui_object_get_child_next(struct gui_object *obj);

struct gui_object *gui_object_get_child_priv(struct gui_object *obj);

int gui_object_into_child(struct gui_console *console);//ok

int gui_object_go_back_to_parent(struct gui_console *console);//menu

int gui_object_go_peer_next(struct gui_console *console);//down

int gui_object_go_peer_priv(struct gui_console *console);//up

#ifdef __cplusplus
}
#endif

#endif
